package com.weed.core;

//$Id: JDBCException.java 4626 2004-09-27 15:24:38Z oneovthafew $


import com.weed.core.*;
import java.sql.SQLException;

/**
 *  JDBC异常封常，用于获得异常同时给出解决方式。
 *
 * @see java.sql.SQLException
 * @author Gavin King
 */
public class JDBCException
    extends WeedException {

  private SQLException sqle;
  private String sql;

  public JDBCException(String string, SQLException root) {
    super(string, root);
    sqle = root;
  }

  public JDBCException(String string, SQLException root, String sql) {
    this(string, root);
    this.sql = sql;
  }

  /**
   * Get the SQLState of the underlying <tt>SQLException</tt>.
   * @see java.sql.SQLException
   * @return String
   */
  public String getSQLState() {
    return sqle.getSQLState();
  }

  /**
   * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt>.
   * @see java.sql.SQLException
   * @return int the error code
   */
  public String getErrorCode() {
      return String.valueOf(sqle.getErrorCode());
  }

  /**
   * Get the underlying <tt>SQLException</tt>.
   * @return SQLException
   */
  public SQLException getSQLException() {
    return sqle;
  }

  /**
   * Get the actual SQL statement that caused the exception
   * (may be null)
   */
  public String getSQL() {
    return sql;
  }

}
